<?php


header("content-typ:text/html; charset=utf-8");

class Car {
    //属性
	public $carMode; //存放车的型号
	public $carBand; //存放车的品牌
	public $weight;  //车的重量
	public $speed;   //车的速度
    //方法

    //与类名相同，构造函数，
    //用于对象创建时给属性一次性赋值
	function Car($m,$b,$w,$s){
       $this->carMode = $m;
	   $this->carBand = $b;
	   $this->weight = $w;
	   $this->speed = $s;
	}

	function getWeight(){
		return $this->weight;
	}
	function getSpeed(){
		return $this->speed;
	}
}

//使用类来创建新的对象，实例化
$car1 = new Car("捷达","大众",1.5,160);
echo"<pre>";
print_r($car1);
echo $car1->getSpeed();
echo $car1->getWeight();


class BMWCar extends Car {}

$bmw1 = new BMWCar("宝马","大众",2,200);
echo "<per>";
print_r($bmw1);
echo $bmw1->getSpeed();